import time

from common.base import Base, By, Select


class ReceivingAddress(Base):
    """
    收货地址
    """
    def input_country(self, text):
        # 国家选择框
        self.drop_down_box((By.ID, 'selCountries_0'), text)

    def input_province(self, text):
        # 省选择框
        self.drop_down_box((By.ID, 'selProvinces_0'), text)

    def input_city(self, text):
        # 市选择框
        self.drop_down_box((By.ID, 'selCities_0'), text)

    def input_district(self, text):
        # 区选择框
        self.drop_down_box((By.ID, 'selDistricts_0'), text)

    def input_consignee(self, consignee):
        # 收货人
        self.find_element((By.ID, 'consignee_0')).send_keys(consignee)

    def input_email(self, email):
        # 电子邮件默认,先清空,再输入指定的邮件地址
        self.clear((By.ID, 'email_0'))
        self.find_element((By.ID, 'email_0')).send_keys(email)

    def input_address(self, address):
        # 收货地址
        self.find_element((By.ID, 'address_0')).send_keys(address)

    def input_zip_code(self, zipcode):
        # 邮政编码
        time.sleep(2)
        self.find_element((By.ID, 'zipcode_0')).send_keys(zipcode)

    def input_phone(self, tel):
        # 电话号码
        self.find_element((By.ID, 'tel_0')).send_keys(tel)

    def input_submit(self):
        # 新增收货地址确认按键
        self.click((By.CLASS_NAME, 'bnt_blue_2'))

